//
//  LoginViewModel.m
//  bus
//
//  Created by hychen on 2017/4/5.
//  Copyright © 2017年 Hychen. All rights reserved.
//

#import "LoginViewModel.h"


@implementation LoginViewModel

- (void)requestLoginWithParams:(NSArray *)param success:(NetWorkSuccessBlock)success failure:(NetWorkFailureBlock)failure{
    WeakSelf_bb
    [[NetworkTool sharedNetworkTool] requestLoginWithParams:param Success:^(UserInfoModel *model) {
        
        [[NSUserDefaults standardUserDefaults] setObject:model.password forKey:@"loginPassword"];
        
        weakSelf.userInfoModel = model;
        [GlobalManage sharedManage].userInfoModel = model;
        [GlobalManage sharedManage].account = model.account;
        [GlobalManage sharedManage].headImageUrl = model.logo_url;
        RequestMessage *req = [[RequestMessage alloc] init];
        req.header.httpheader.username = model.account;
        req.header.httpheader.password = model.password;
        success(model);
    } Failure:^(NSString *code, NSString *msg) {
        if (failure) {
            failure(code,msg);
        }
    }];
}

@end
